package main

import (
	"fmt"
	"net"
)

func main (){
	fmt.Println("start server...")
	//简历监听
	listen ,err := net.Listen("tcp","localhost:8000")
	if err !=nil{
		fmt.Println("监听失败", err)
		return
	}
	for{
		//获取链接
		con, err := listen.Accept()
		if err != nil  {
			fmt.Println("简历链接失败", err)
			continue
		}
		//新建线程处理链接
		go delCon(con)
	}
	
}
func delCon(con net.Conn)  {
	defer con.Close()
	for{
		buf := make([]byte,512)
		n, err := con.Read(buf)
		if err!= nil{
			fmt.Println("连接中读取数据失败",err)
			return
		}
		fmt.Printf("read %s",string(buf[0:n]))
	}

}
